#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.log.convert;

import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import org.slf4j.LoggerFactory;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 *@ClassName IpLogConfig
 *@Description 配置日志中显示IP
 *@Author zhanglijun
 *@Date 2020/1/13 15:10
 *
 *${copyright}
 *Copyright (c) 2019. All Rights Reserved.
 */
public class IpLogConfig extends ClassicConverter {
    private static final Logger logger = (Logger) LoggerFactory.getLogger(IpLogConfig.class);
    private static String webIP;
    static {
        try {
            webIP = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            logger.error("获取日志Ip异常", e);
            webIP = null;
        }
    }

    @Override
    public String convert(ILoggingEvent event) {
        return webIP;
    }



}
